<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <h1>工程首页</h1>
    <h2>欢迎{{user.nickname}}回来!</h2>
    <a href="javascript:void(0)" @click="logout()">退出登录</a>
    <a href="/post.html">发微博</a>
    <!--相对路径:相对于当前页面所处位置-->
    <a href="bmi.html">BMI测试</a>
    <!--绝对路径:/代表的是工程根路径(http://localhost:8080/)-->
    <a href="/bmiAsync.html">BMI测试(异步)</a>
    <hr>
    <a href="/reg.html">注册</a>
    <a href="/login.html">登录</a>
    <hr>
    <a href="/list.html">微博列表</a>
</div>
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<!--引入axios框架文件-->
<script src="https://cdn.bootcss.com/axios/0.18.0/axios.min.js"></script>
<script>
    let v = new Vue({
        el:"body>div",
        data:{
            user:localStorage.user?JSON.parse(localStorage.user):null
        },
        methods:{
            logout(){
                if (confirm("您确认退出登录吗?")){
                    axios.get("/logout").then(function () {
                        //清空localStorage里面的数据
                        localStorage.clear();
                        location.href="/login.html";
                    })
                }
            }
        }
    })
</script>



</body>
</html>